﻿using System.Collections.Generic;
using System.Text;

namespace JsiCommon.javaScriptInterop
{
    public class JsiFunctionCall : IJsiExpression
    {
        private readonly IJsiExpression _function;
        private readonly IEnumerable<IJsiExpression> _argList;

        public JsiFunctionCall(IJsiExpression function, IEnumerable<IJsiExpression> argList)
        {
            _function = function;
            _argList = argList;
        }

        public void Compile(StringBuilder builder)
        {
            _function.Compile(builder);
            builder.Append('(');
            JsiExpressionHelper.StringBuilderJoin(builder, ",", _argList);
            builder.Append(')');
        }
    }
}